package com.google.android.gms.internal;

import com.google.android.exoplayer2.C;
import com.google.android.gms.internal.zzdwp;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public final class zzdtl<P> {
    private static final Charset UTF_8 = Charset.forName(C.UTF8_NAME);
    private ConcurrentMap<String, List<zzdtm<P>>> zzmev = new ConcurrentHashMap();
    private zzdtm<P> zzmew;

    /* access modifiers changed from: protected */
    public final zzdtm<P> zza(P p, zzdwp.zzb zzb) throws GeneralSecurityException {
        byte[] bArr;
        byte b;
        ByteBuffer byteBuffer;
        switch (zzdtc.zzmes[zzb.zzbrr().ordinal()]) {
            case 1:
            case 2:
                byteBuffer = ByteBuffer.allocate(5);
                b = 0;
                break;
            case 3:
                byteBuffer = ByteBuffer.allocate(5);
                b = 1;
                break;
            case 4:
                bArr = zzdtb.zzmer;
                break;
            default:
                throw new GeneralSecurityException("unknown output prefix type");
        }
        bArr = byteBuffer.put(b).putInt(zzb.zzbrq()).array();
        zzdtm<P> zzdtm = new zzdtm<>(p, bArr, zzb.zzbrp(), zzb.zzbrr());
        ArrayList arrayList = new ArrayList();
        arrayList.add(zzdtm);
        String str = new String(zzdtm.zzboh(), UTF_8);
        List list = (List) this.zzmev.put(str, Collections.unmodifiableList(arrayList));
        if (list != null) {
            ArrayList arrayList2 = new ArrayList();
            arrayList2.addAll(list);
            arrayList2.add(zzdtm);
            this.zzmev.put(str, Collections.unmodifiableList(arrayList2));
        }
        return zzdtm;
    }

    /* access modifiers changed from: protected */
    public final void zza(zzdtm<P> zzdtm) {
        this.zzmew = zzdtm;
    }

    public final zzdtm<P> zzbof() {
        return this.zzmew;
    }
}
